import Vue from 'vue'
import Vuex from 'vuex'

//使用vuex
Vue.use(Vuex)

//导出store
export default new Vuex.Store({
     //将数据定义在state里面，state是一个对象
     state: {
     
        count: 250,
        user_name:'' || JSON.parse(localStorage.getItem('userinfo')),
        // company_info:'' || JSON.parse(sessionStorage.getItem('company_info')),
        // 存储token
        // Authorization: localStorage.getItem('Authorization') ? localStorage.getItem('Authorization') : ''
    },
    mutations: {
        // 修改token，并将token存入localStorage
        // changeLogin (state, token) {
        //     state.Authorization = token;
        //     localStorage.setItem('Authorization',token);
        // },
      
        SET_USER(state, user) {
            state.user_name = JSON.parse(user)
            localStorage.setItem('user_info',user);
        },
        

    }, 
    // getters 依赖 state 中的成员去更新
    getters: {  
        user: state => state.user_name,
        company:state => state.company_info
    }



    
})